package zgs;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class ReadStringDemo {
    public static void main(String[] args) throws IOException {
       /* File file = new File("./fos.txt");
        long length = file.length();
        System.out.println("文件大小:"+length);
        byte[] data = new byte[(int)length];
        FileInputStream fis = new FileInputStream(file);
        fis.read(data);
        String line = new String(data, StandardCharsets.UTF_8);
        System.out.println(line);
        fis.close();*/

        File file = new File("./fos.txt");
        long length = file.length();
        System.out.println("文件大小:"+length);
        byte[] data = new byte[(int)length];
        FileInputStream fis = new FileInputStream(file);
        fis.read(data);
        String line = new String(data, StandardCharsets.UTF_8);
        fis.close();


    }
}
